<?php
$mu = Session::get('mu');
// $wid = Session::get('wid');
// dump($mu->id);die;
if (!$mu->id) {
	Redirect::to('/manage/login.html');
}

$kefu = (new Model('qy_kefu'))->find(['mid' => $mu->id]);

if (Request::post('image')) {
	setApi();
	if (!$kefu->url) {
		// echo 1;die;
		$kefu = new Model('qy_kefu');
		$kefu->url = Request::post('image');
		$kefu->mid = $mu->id;
		$res = $kefu->save();
		// dump($res);
		$msg=['status'=>'success','msg'=>"成功"];
		sendSuccess('设置成功',$msg);
		die;
	} else {
		// echo 2;die;
		$kefu->url = Request::post('image');
		$kefu->save();
		$msg=['status'=>'success','msg'=>"成功"];
		sendSuccess('设置成功',$msg);	
		die;
	}
}
